1. Field of the Invention
The present invention relates to an image processing apparatus that detects luminance values of a background by analyzing a luminance histogram of an image, to a luminance correction method, and to a storage medium storing a program.
2. Description of the Related Art
A reading apparatus called a scanner is known that optically reads documents such as document originals and images such as photographs, and converts the read documents and images into electronic data. In general, when a document original has been read by the reading apparatus, a background does not have the maximum luminance (255 in the case of a color image of RGB channels each having 8 bits), thereby causing various problems. For example, if the read image is displayed on a display apparatus, a dynamic range of the image will decrease. Also, if the read image is printed by a printing apparatus such as a printer, the running cost will increase as coloring material is ejected for the background as well. Furthermore, if the read image is stored in a compressed state in a storage apparatus such as a hard disk drive, the compression ratio will be reduced as the background has signal values, thereby lowering the efficiency of memory use.
For the aforementioned reasons, background removal processing for removing the color of the background is generally applied to the read image. For example, as the background removal processing, a method is known for estimating the luminance values of the background from the result of analyzing the image, and converting luminance values that are equal to or larger than the estimated luminance values into the maximum luminance; in this method, it is important to appropriately estimate the luminance values of the background.
In Japanese Patent Laid-Open No. 09-167227, a luminance histogram of an image including a subject and a background is obtained. Then, the frequency corresponding to the maximum luminance value out of the frequencies representing local peaks is determined as an axis, the shape of a histogram defined by the axis and the substantially maximum luminance value is flipped toward the lower luminance side over the axis, and the resultant histogram is used as a histogram corresponding only to the background (the luminance distribution of the background). Japanese Patent Laid-Open No. 09-167227 takes advantage of the fact that the histogram corresponding only to the background shows distribution that is bilaterally symmetrical with respect to the luminance value corresponding to the peak frequency.
In Japanese Patent Laid-Open No. 2001-197308, a density tone histogram is generated for an image including a background, characters, and the like. Then, a peak tone value corresponding to a peak frequency is calculated, a first tone value corresponding to a predetermined frequency threshold on the lower tone side of the peak tone value is obtained, and a reference threshold (the end point of distribution corresponding to the background) is calculated by adding, to the peak tone value, a value of a difference between the peak tone value and the first tone value. Japanese Patent Laid-Open No. 2001-197308 also takes advantage of the fact that the histogram obtained from an image including only the background shows distribution that is bilaterally symmetrical with respect to the peak tone value. The luminance distribution of the background can be obtained by utilizing the aforementioned nature of the histogram of the background that shows bilaterally symmetrical distribution.
Although the luminance distribution of the background is bilaterally symmetrical with respect to the axis, i.e. the peak value, the luminance distribution of areas other than the background, which are formed by coloring material ejected onto the background, is not always bilaterally symmetrical with respect to the axis, i.e. the peak value depending on the amount of the coloring material and the way the coloring material is ejected. FIG. 10 shows the luminance distribution of a background, the luminance distributions of various light colors, and the composite distribution thereof. As shown in FIG. 10, in the case where the luminance distributions of various light colors exist in the vicinity of the lower luminance side of the luminance distribution of the background, the peak value A′ of the composite distribution thereof shifts toward the lower luminance side of the peak value A of the luminance distribution of the background. This is because the background, which has the maximum luminance in the image and a large area (high frequency), is influenced by the luminance distributions of light colors overlapping in the vicinity of the lower luminance side of the luminance distribution of the background.
Neither Japanese Patent Laid-Open No. 09-167227 nor Japanese Patent Laid-Open No. 2001-197308 takes into consideration the fact that, in the case where the luminance distributions of light colors are composited with the luminance distribution of the background in the vicinity of the lower luminance side of the luminance distribution of the background, the peak value of the composite distribution actually shifts toward the lower luminance side. For this reason, if the shape of the histogram of the composite distribution on the higher luminance side is flipped over the axis passing through the peak of the composite distribution, the edge of the resultant symmetry line on the lower luminance side has lower luminance than the edge B of the actual luminance distribution of the background. If the background removal processing is executed based on the detected edge of the luminance distribution of the background, light colors are unnecessarily removed. As light colors, in some cases, serve as information that has been intentionally added by a creator of a document original for distinction from the background, unnecessary removal of light colors leads to loss of such information.